/*
 * @Autor: dingxiaolin
 * @Date: 2021-06-10 10:11:43
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-07-28 18:11:22
 */
import { ObjectDirective } from 'vue'
import PerfectScrollbar from 'perfect-scrollbar'
const el_scrollBar = (el) => {
    el.setAttribute('style', 'position:relative;overflow:hidden')
    if (el._ps_ instanceof PerfectScrollbar) {
        el._ps_.update()
    } else {
        el._ps_ = new PerfectScrollbar(el, {
            suppressScrollX: true,
            wheelSpeed: 1,
            wheelPropagation: true,
            minScrollbarLength: 0
        })
    }
}

export const scrollBar: ObjectDirective = {
    mounted(el: HTMLButtonElement, vnode) {
        el_scrollBar(el)
    }
}
